package com.rdxer.service;

import com.rdxer.core.utils.SearchUtils;
import com.rdxer.core.utils.search.SearchPara;
import org.springframework.data.domain.Page;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import java.io.Serializable;
import java.util.List;

public interface CRUDPageServiceInterface<T, ID extends Serializable> extends CRUDServiceInterface<T,ID> {

    ///////////////////////////////////// page
    /**
     * 条件查询+分页
     */
    default Page<T> search(SearchPara para) {
        JpaSpecificationExecutor<T> resp = (JpaSpecificationExecutor<T>) getRepository();
        return SearchUtils.searchByPage(resp, para);
    }
    /**
     * 条件查询
     */
    default List<T> searchNoPage(SearchPara para) {
        JpaSpecificationExecutor<T> resp = (JpaSpecificationExecutor<T>) getRepository();
        return SearchUtils.searchAll(resp,para);
    }


}
